﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using OdeToFood.Models;

namespace OdeToFood.Content
{
    public class ReviewsController : Controller
    {
        //
        // GET: /Reviews/

        public ActionResult Index()
        {
            var model = from r in Reviews
                orderby r.Country
                select r;
            return View(model);
        }

        //
        // GET: /Reviews/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /Reviews/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /Reviews/Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Reviews/Edit/5

        public ActionResult Edit(int id)
        {
            var EditModel = Reviews.Single(r => r.Id == id);
            return View(EditModel);
        }

        //
        // POST: /Reviews/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Reviews/Delete/5

        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /Reviews/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        private static readonly List<ResturantReviews> Reviews = new List<ResturantReviews>
        {
            new ResturantReviews
            {
                Id = 1,
                Name = "Sushi",
                City = "Tokyo",
                Country = "Japan",
                Rating = 6
            },
            new ResturantReviews
            {
                Id = 2,
                Name = "Burger",
                City = "Los Angles",
                Country = "USA",
                Rating = 4
            },
            new ResturantReviews
            {
                Id = 3,
                Name = "Kabab",
                City = "Shiraz",
                Country = "Iran",
                Rating = 8
            }
        };


    }
}
